<?php

namespace ms\modules\article\models\searchs;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use ms\modules\article\models\HotPkRank;

/**
 * SearchHotPkRank represents the model behind the search form about `ms\modules\article\models\HotPkRank`.
 */
class SearchHotPkRank extends HotPkRank
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'rank'], 'integer'],
            [['dh_price', 'whole_price', 'disparity'], 'number'],
        	[['name'], 'string', 'max' => 255],
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = HotPkRank::find();

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        if (!($this->load($params) && $this->validate())) {
            return $dataProvider;
        }

        $query->andFilterWhere([
            'id' => $this->id,
            'rank' => $this->rank,
        	'name'=>$this->name,	
            'dh_price' => $this->dh_price,
            'whole_price' => $this->whole_price,
            'disparity' => $this->disparity,
        ]);

        return $dataProvider;
    }
}
